package cn.tedu._07springaop.egaop01;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class OrderServiceAspect {
    @Before(value = "execution(public void cn.tedu._07springaop.egaop01.OrderServiceImpl.placeOrder(..))")
    public void beforeMethod(JoinPoint joinPoint){
        //获取参数
        String name = joinPoint.getSignature().getName();
        int arg = (int) joinPoint.getArgs()[0];
        //校验参数
        if (arg<=0)
            throw new IllegalArgumentException(name+"方法的订单数量必须大于0");

    }
}
